package cn.kgc.springcloud.controller;

import cn.kgc.springcloud.dto.StudentDTO;
import cn.kgc.springcloud.service.StudentService;
import cn.kgc.springcloud.vo.StudentVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: mosin
 * @version: v1.0  2022/8/28
 */
@RestController
@RequestMapping("student")
public class StudentController {

    @Autowired
    private StudentService studentService;
    @GetMapping
    public List<StudentVO> studentList(){
        List<StudentVO> studentVOS = studentService.selectAll();
        return studentVOS;
    }

    @PostMapping
    public StudentVO addStudent(@RequestBody StudentDTO studentDTO){
        StudentVO studentVO = studentService.addStudent(studentDTO);
        return studentVO;
    }
}
